import re

if __name__ == '__main__':
    text = "This is some text -- with punctuation."

    pattern = 'is'

    print('Text   :', text)
    print('Pattern:', pattern)

    # 查找第一个匹配位置
    match = re.search(pattern=pattern, string=text)
    if match:
        s = match.start()
        e = match.end()

        print(s)
        print(e)

    # 从开始位置进行匹配
    match = re.match(pattern=pattern, string=text)
    if match:
        s = match.start()
        e = match.end()

        print(s)
        print(e)

    # 匹配整个字符串
    match = re.fullmatch(pattern=pattern, string=text)
    if match:
        s = match.start()
        e = match.end()

        print(s)
        print(e)
